<?php 
namespace app\home\controller;
use think\Controller;
use think\Db;	
use think\Session;
use think\request;
//登录判断
class Base extends Controller{
    public $request;
	//登录验证
	public function __construct(){
        $this->request = request();
        parent::__construct();
        // $this->assign("logname",'你还没有登录');
        // $time=Session::get('time')+21600;
        //判断用户是否已经登录
        if(!Session::get('uid')){
            $this->error('对不起,您还没有登录!请先登录再进行浏览', ('/index/login/index'), 1);
        }
		  //用户未读的站内信总数
        $ste=Db::name('message')
        ->where('rceID',Session::get('uid'))
        ->where('Statue',0)
        ->where('level',3)
        ->count();
        Session::set('messagesum',$ste);
        		
	}
    //用户信息获取
    static public function userInformation(){
        $uid = Session::get('uid');
        $information = Db::name('users')
        ->where(['id'=>$uid])
        // ->field('id,usercode,name,email,password,paymentPassword,phonenumber,balance,Frozenfunds,fixedtelephone,creationtime,register,')
        ->find();
        return $information;
    }

    //唯一流水号
    public function makeSn(){
        return date('YmdHis')
        . sprintf('%03d', (float)microtime() * 1000)
        . rand(1000,9999);
    }

    static public function find_log_balance(){
        $res=Db::name('cashlog')
            ->field('balance')
            ->where('uid',Session::get('uid'))
            ->order('id desc')
            ->find()['balance'];
        return $res;
    }    
    
}

?>